package com.next.aappublicapp.util;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.MenuItem;

import com.google.analytics.tracking.android.EasyTracker;
import com.next.aappublicapp.R;
import com.next.aappublicapp.SettingsActivity;
import com.next.aappublicapp.UserProfileActivity;

public class MenuUtil {

	public static Boolean onOptionsItemSelected(MenuItem item, Activity activity) {

		switch (item.getItemId()) {
		case R.id.action_settings:
			Intent settingintent = new Intent(activity, SettingsActivity.class);
			activity.startActivity(settingintent);
			EasyTracker.getTracker().sendEvent("Android", "Manu", "Settings",
					1L);
			return true;

		case R.id.action_profile:
			if (UserProfileUtil.isUserProfiledSavedByUser(activity)) {
				Intent userProfileintent = new Intent(activity,
						UserProfileActivity.class);
				activity.startActivity(userProfileintent);
				EasyTracker.getTracker().sendEvent("Android", "Manu",
						"Edit Profile", 1L);
			} else {
				AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
						activity);
				alertDialogBuilder.setTitle("Errors");
				alertDialogBuilder
						.setMessage("You have not created a profile yet. Next time login using facebook and create your profile");

				alertDialogBuilder.setPositiveButton("Ok",
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
								dialog.dismiss();
							}
						});
				// create alert dialog
				AlertDialog alertDialog = alertDialogBuilder.create();

				// show it
				alertDialog.show();
			}
			return true;

		default:
			return null;
		}
	}
}
